package com.hondee.fuzzyquery.entity.access;

public enum OrderType {
	
	ASC("ASC"),
	DESC("DESC");
	
	private String typeStr;
	
	private OrderType(String typeStr){
		this.typeStr = typeStr;
	}
	
	public String getTypeStr(){
		return typeStr;
	}
	
	public static OrderType get(Object value){
		if(value==null){
			throw new RuntimeException("Order value is null.");
		}
		String string = value.toString().toUpperCase();
		
		if(string.equals(ASC.typeStr)){
			return ASC;
		}else if(string.equals(DESC.typeStr)){
			return DESC;
		}else {
			throw new RuntimeException("No such order type");
		}
	}
}
